﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace EvoWars.Stuffs
{

    /// <summary>
    /// Represents the current viewable area in the world.
    /// 'Position' is the top left corner of the viewable area.
    /// </summary>
    public class Camera2D
    {
        public Vector2 Position { get; set; }
        public int Width { get; set; }
        public int Height { get; set; }

        public Camera2D()
        {
            Position = new Vector2();
        }

        public Camera2D(Vector2 pos)
        {
            Position = pos;
        }


        public void MoveCamera(Vector2 moveVector)
        {
            Position += moveVector;
        }

        public Vector2 GetRenderPosition(Vector2 spritePosition)
        {
            Vector2 finalPosition = spritePosition - Position;
            return finalPosition;
        }



        public void CenterOnPoint(Vector2 point)
        {
            float newX = (float)(point.X - this.Width / 2.0);
            float newY = (float)(point.Y - this.Height / 2.0);

            Vector2 newPosition = new Vector2(newX, newY);

            this.Position = newPosition;
        }
    }
}
